import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore('user', () => {
  const username = ref('')
  const uuid = ref('')
  const isCustomerService = ref(false)

  function setUser(data: { username: string; uuid?: string; isCustomerService?: boolean }) {
    username.value = data.username
    if (data.uuid) uuid.value = data.uuid
    if (data.isCustomerService !== undefined) isCustomerService.value = data.isCustomerService
  }

  function clearUser() {
    username.value = ''
    uuid.value = ''
    isCustomerService.value = false
  }

  return {
    username,
    uuid,
    isCustomerService,
    setUser,
    clearUser
  }
})